package com.dwy2002.common.utils;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.dwy2002.common.config.MyOssConfig;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * spring管理OSS实例
 *
 * @author 杜伟毅
 * @version 1.0
 * @since 2025/06/05
 */
@Configuration
@RequiredArgsConstructor
public class OssClientConfig {
    private final MyOssConfig config;

    @Bean
    public OSS ossClient() {
        return new OSSClientBuilder().build(
                config.getEndpoint(),
                config.getAccessKeyId(),
                config.getAccessKeySecret()
        );
    }
}
